<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>热量计算</title>
	<link rel="stylesheet" href="../css/jeui.css"  media="all">
	<script type="text/javascript" src="../js/modules/jeui.js"></script>
	<style type="text/css">
		.c1 {
		    background: linear-gradient(#ffd183 , #ffaa42);
		}
		.c2 {
		    background: linear-gradient(#ffb9b9 , #ff8888);
		}
		.c3 {
		    background: linear-gradient(#aebaff , #ac67ff);
		}
		.c4 {
		    background: linear-gradient(#bee0ff , #32aafa);
		}
		.c5{
			background: linear-gradient(#faaa98, #ff6b48);
		}
		.c6{
			background: linear-gradient(#87e7e5 , #00cec9);
		}
		.c7{
			background: linear-gradient(#73A6D6 , #487eb0);
		}
		.je-progress {
			background-color: rgba(255, 255, 255, 0.3);
		}
		.je-bg-bar {
		    background-color: rgba(46,46,46,.42);
		}
	</style>
</head>
<body>
	<div>
		<ul id="box">
			
		</ul>
	</div>
    <script src="https://cdn.wilddog.com/sdk/js/2.5.17/wilddog.js"></script>
    <script src="../js/dataserver.js"></script>
	<script type="text/javascript">
		jeui.use(["jquery","jeProgress","utils"],function () {
			var checknum = 0,yearday = getDayNum(),everydata = [],behaviorsdata = [];

			data_getAllFrom("mydata/every",function (data) {
				checknum++;
				everydata = data;
				if(checknum === 2){
					initall();
				}
			});

	        data_getAllFrom("mydata/behaviors",function (data) {
				checknum++;
				behaviorsdata = data;
				if(checknum === 2){
					initall();
				}
	        });

	        function initall() {
	        	var allnumber = {};
	        	for(key in behaviorsdata){
	        		if(key != "details"){
	        			var obj  = {};
	        			obj.bl = behaviorsdata[key].fs;
	        			obj.zf = behaviorsdata[key].gh*yearday;
	        			obj.df = 0;
	        			allnumber[behaviorsdata[key].mc] = obj;
	        		}
	        	}
	        	for(key in everydata){
	        		if(key != "details"){
	        			var thisobj = allnumber[everydata[key].behavior];
	        			thisobj.df += parseInt(everydata[key].grade)*parseInt(thisobj.bl);
	        		}
	        	}

	        	// console.log(allnumber);
	        	getview(allnumber);
	        }


	        function getview(obj) {
				var html = [];
				var i = 0;
				for(key in obj){
					var dfbl = (obj[key].df/obj[key].zf)*100;
					i++;
					html.push('<li class="je-p15 je-m10 je-w30 je-fl c'+i+'">');
					html.push('	<h2 class="je-tc je-f20 je-white">'+key+'</h2>');
					html.push('	<div class="je-progress je-progress-big je-m10" showtext="true">');
					html.push('	  <div class="je-progress-bar je-bg-bar" percent="'+dfbl+'%"></div>');
					html.push('	</div>');
					html.push('</li>');
				}
				$("#box").html(html.join(""));
				$(".je-progress").jeProgress();
	        }

			
		});
	</script>
</body>
</html>